home *** CD-ROM | disk | FTP | other *** search
/ CD Ware Multimedia 1995 May / cd Ware (Juegos) Epimundo.iso / DOS / C / TINY_WP.ZIP / MODEM.C < prev    next >
Encoding:
C/C++ Source or Header  |  1989-05-16  |  1.5 KB  |  76 lines

  1. /* ------------ modem.c --------- */
  2.  
  3. #include <dos.h>
  4. #include <conio.h>
  5. #include "serial.h"
  6. #include "modem.h"
  7.  
  8. char DIAL[] = "ATDT";
  9. char PHONENO[21];
  10.  
  11. int direct_connection;    /* true if connected without a modem */
  12.  
  13. /* ----------- write a command to the modem ------------ */
  14. static void modout(char *s)
  15. {
  16.     while(*s)    {
  17.         if (*s == '~')
  18.             sleep(1);
  19.         else if (!writecomm(*s))
  20.             break;
  21.         s++;
  22.     }
  23. }
  24.  
  25. /* ----------- initialize the modem ---------- */
  26. void initmodem(void)
  27. {
  28.     intercept_timer();
  29.     initcomport();
  30.     if (!direct_connection)    {
  31.         modout(RESETMODEM);
  32.         modout(INITMODEM);
  33.         clear_serial_queue();
  34.     }
  35. }
  36.  
  37. /* -------- release the modem --------- */
  38. void release_modem(void)
  39. {
  40.     if (!direct_connection)
  41.         modout(RESETMODEM);
  42.     restore_timer();
  43.     restore_serialint();
  44.     clear_serial_queue();
  45. }
  46.  
  47. /* ----------- place a call -------------- */
  48. void placecall(void)
  49. {
  50.     if (!direct_connection)    {
  51.         modout(DIAL);
  52.         modout(PHONENO);
  53.         modout("\r");
  54.         clear_serial_queue();
  55.     }
  56. }
  57.  
  58. /* ------------- answer a call ------------ */
  59. void answercall(void)
  60. {
  61.     if (!direct_connection)    {
  62.         modout(ANSWER);
  63.         clear_serial_queue();
  64.     }
  65. }
  66.  
  67. /* ------------ disconnect the call ----------------- */
  68. void disconnect(void)
  69. {
  70.     if (!direct_connection)    {
  71.         modout(HANGUP);
  72.         clear_serial_queue();
  73.     }
  74. }
  75.  
  76.